﻿<!-- #layout name=blank-->
<div class="page-header">
    <h1 class="title">Synchronization</h1>
</div>
<div data-bind="component: { name: 'kb-breadcrumb' , params:[{
    name: 'SITES'
},{
    name: 'DASHBOARD'
},{
    name: Kooboo.text.common.sync
}]}"></div>
<div class="navbar navbar-default">
    <div class="container-fluid">
        <a data-bind="click: showSyncModal" class="btn green navbar-btn">Create</a>
        <a data-bind="visible: showDeleteBtn, click: onDelete" class="btn red navbar-btn">Delete</a>
    </div>
</div>

<div data-bind="component: { name: 'kb-table', params: tableData }"></div>

<div data-bind="modal: syncModal" class="modal fade" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button data-bind="click: hideSyncModal" class="close"><i class="fa fa-close"></i></button>
                <h4 class="modal-title">New publishing</h4>
            </div>
            <div class="modal-body">
                <div class="form-horizontal">
                    <div id="remote-login">
                        <div class="form-group">
                            <label class="control-label col-md-2">Server</label>
                            <div class="col-md-10">
                                <div class="form-inline">
                                    <select data-bind="value: server, options: servers, optionsText: 'name', optionsValue: 'serverUrl'" class="form-control input-xlarge"></select>
                                    <button class="btn btn-default pull-right" data-bind="click: configServer, attr: { title: Kooboo.text.common.config }"><i class="fa fa-gear"></i></button>
                                </div>
                            </div>
                        </div>
                        <div class="form-group site" data-bind="collapsein: selectSiteStep">
                            <label class="control-label col-md-2 ">Site name</label>
                            <div class="col-md-10">
                                <div class="form-inline">
                                    <select data-bind="value: choosedSiteId, options: avaliableSites, optionsText: 'name', optionsValue: 'id'" class="form-control input-xlarge"></select>
                                    <button class="btn btn-default pull-right" data-bind="click: onShowSiteModal, attr: { disabled: !ableToAddSite() }"><i class="fa fa-plus"></i></button>
                                </div>
                            </div>
                        </div>
                        <div class="form-group" data-bind="collapsein: selectSiteStep">
                            <div class="col-md-10 col-md-offset-2" data-bind="foreach: pushTypes">
                                <label class="radio-inline">
                                    <input type="radio" name="pushType" data-bind="value: $data.value, checked: $parent.pushType">
                                    <!-- ko text: $data.displayName --><!-- /ko -->
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button data-bind="click: next, visible: !selectSiteStep()" class="btn blue">Next</button>
                <button data-bind="click: save, visible: selectSiteStep" class="btn blue">Save</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" data-bind="modal: showServersModal" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-bind="click: onHideServersModal"><i class="fa fa-close"></i></button>
                <h4 class="modal-title">Manage servers</h4>
            </div>
            <div class="modal-body">
                <div class="table-responsive">
                    <table class="table table-striped table-hover">
                        <thead>
                            <tr>
                                <th>Server name</th>
                                <th>Server address</th>
                                <th class="table-action"></th>
                                <th class="table-action"></th>
                            </tr>
                        </thead>
                        <tbody data-bind="foreach: editableServers">
                            <!-- ko ifnot: $data.reserved() -->
                            <tr data-bind="visible: !editMode()">
                                <td data-bind="text: $data.name"></td>
                                <td data-bind="text: $data.serverUrl"></td>
                                <td class="table-action"><button class="btn btn-xs blue" data-bind="click: editServer, tooltip: Kooboo.text.common.edit"><i class="fa fa-pencil"></i></button></td>
                                <td class="table-action"><button class="btn btn-xs red" data-bind="click: $parent.removeServer, tooltip: Kooboo.text.common.delete"><i class="fa fa-close"></i></button></td>
                            </tr>
                            <tr data-bind="visible: editMode()">
                                <td>
                                    <input type="text" class="form-control" data-bind="value: $data.editableName, error: $data.editableName, errorPlacement: 'top'">
                                </td>
                                <td>
                                    <input type="text" class="form-control" data-bind="value: $data.editableUrl, error: $data.editableUrl, errorPlacement: 'top'">
                                </td>
                                <td class="table-action"><button class="btn btn-xs blue pull-right" data-bind="click: $parent.saveServer.bind(this, $data), attr: { title: Kooboo.text.common.save }"><i class="fa fa-save"></i></button></td>
                                <td class="table-action"><button class="btn btn-xs red pull-right" data-bind="click: $parent.cancelEdit.bind(this, $data), attr: { title: Kooboo.text.common.cancel }"><i class="fa fa-close"></i></button></td>
                            </tr>
                            <tr style="display: none;">
                                <td colspan="100"></td>
                            </tr>
                            <!-- /ko -->
                        </tbody>
                    </table>
                    <button class="btn btn-default" data-bind="click: addNewServer, visible: ableToAddNewServer"><i class="fa fa-plus"></i></button>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-bind="click: onHideServersModal">Ok</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" data-bind="modal: showSiteModal" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-bind="click: onHideSiteModal"><i class="fa fa-close"></i></button>
                <h4 class="modal-title">Create a new site</h4>
            </div>
            <div class="modal-body">
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="control-label col-md-2">Site name</label>
                        <div class="col-md-10">
                            <input type="text" class="form-control input-medium" data-bind="value: remoteSiteName, error: remoteSiteName" placeholder="Site name">
                            <span class="help-block">Start with letters and no space allowed.</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">Domain</label>
                        <div class="col-md-10">
                            <div class="form-inline">
                                <input type="text" class="form-control input-medium" data-bind="value: remoteSiteDomain, error: remoteSiteDomain" placeholder="Sub domain">
                                <select class="form-control" data-bind="options: avaliableRemoteDomain, optionsText: 'domainName', optionsValue: 'domainName', value: remoteDomain"></select>
                            </div>
                            <span class="help-block">Give your site a domain that other people can access.</span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn green" data-bind="click: createRemoteSite">Create</button>
                <button class="btn gray" data-bind="click: onHideSiteModal">Cancel</button>
            </div>
        </div>
    </div>
</div>
<script>
    (function() {
        Kooboo.loadJS([
            "/_Admin/Scripts/kooboo/Guid.js",
            "/_Admin/Scripts/components/kbTable.js",
            "/_Admin/Scripts/components/kbBreadcrumb.js",
            "/_Admin/Scripts/SPA.js",
            "/_Admin/Scripts/tableModel.js"
        ])
    })()
</script>
<script src="/_Admin/View/Sync.js"></script>